#include "advancedconigdialog.h"
#include <QGroupBox>
#include <QTextEdit>
#include <QCheckBox>
#include <QRadioButton>
#include <QLabel>
#include <QFormLayout>
#include <QComboBox>
#include <QLineEdit>
#include <QPushButton>

AdvancedConigDialog::AdvancedConigDialog():
    m_pIPSelectComboBox(new QComboBox),
    m_pDHCPRadioButton(new QRadioButton(tr("DHCP"))),
    m_pSTATICRadioButton(new QRadioButton(tr("STATIC"))),
    m_pIPLineEdit(new QLineEdit),
    m_pSubnetMaskLineEdit(new QLineEdit),
    m_pDefaultGatewallLineEdit(new QLineEdit),
    m_pNetSaveAndRebootButton(new QPushButton(tr("Save&Reboot"))),

    m_pHostComboBox(new QComboBox),
    m_p50RadioButton(new QRadioButton("50")),
    m_p100RadioButton(new QRadioButton("100")),
    m_p150RadioButton(new QRadioButton("150")),
    m_p200RadioButton(new QRadioButton("200")),
    m_pAutoRadioButton(new QRadioButton("Auto")),
    m_pRebootButton(new QPushButton(tr("Reboot"))),
    m_pFunSaveAndRebootButton(new QPushButton(tr("Save Reboot"))),

    m_pEDIDComboBox(new QComboBox),
    m_pEDIDComboBox2(new QComboBox),
    m_pReadButton(new QPushButton(tr("Fetch"))),
    m_pReadButton2(new QPushButton(tr("Fetch"))),
    m_pTextEdit(new QTextEdit),
    m_pEditCheckBox(new QCheckBox(tr("Edit"))),
    m_pHDMICheckBox(new QCheckBox(tr("Default HDMI"))),
    m_pDVICheckBox(new QCheckBox(tr("Default DVI"))),
    m_pEDIDHostComboBox(new QComboBox),
    m_pWriteInButton(new QPushButton(tr("Write In")))
{
    setObjectName("AdvancedConigDialog");
    resize(800,400);
    //net
    QHBoxLayout *ipModelHLayout=new QHBoxLayout;
    ipModelHLayout->addWidget(m_pDHCPRadioButton);
    ipModelHLayout->addWidget(m_pSTATICRadioButton);

    QFormLayout *formLayout=new QFormLayout;
    formLayout->addRow(tr("IP Select:"),m_pIPSelectComboBox);
    formLayout->addRow(tr("IP Model:"),ipModelHLayout);
    formLayout->addRow(tr("IP Addr:"),m_pIPLineEdit);\
    formLayout->addRow(tr("Subnet Mask:"),m_pSubnetMaskLineEdit);
    formLayout->addRow(tr("Default Gate"),m_pDefaultGatewallLineEdit);

    QHBoxLayout *buttonHLayout=new QHBoxLayout;
    buttonHLayout->addStretch(1);
    buttonHLayout->addWidget(m_pNetSaveAndRebootButton);

    QVBoxLayout *netLayout=new QVBoxLayout;
    netLayout->addLayout(formLayout);
    netLayout->addLayout(buttonHLayout);

    QGroupBox *netGroupBox=new QGroupBox;
    netGroupBox->setObjectName("netGroupBox");
    netGroupBox->setTitle(tr("Net"));
    netGroupBox->setLayout(netLayout);

    //function
    QHBoxLayout *hostHLayout=new QHBoxLayout;
    hostHLayout->addStretch(1);
    hostHLayout->addWidget(m_pHostComboBox);

    QLabel *label=new QLabel("[Mbps]");
    QHBoxLayout *bitHLayout=new QHBoxLayout;
    bitHLayout->addWidget(m_p50RadioButton);
    bitHLayout->addWidget(m_p100RadioButton);
    bitHLayout->addWidget(m_p150RadioButton);
    bitHLayout->addWidget(m_p200RadioButton);
    bitHLayout->addWidget(m_pAutoRadioButton);
    bitHLayout->addWidget(label);

    QGroupBox *bitGroupBox=new QGroupBox;
    bitGroupBox->setObjectName("bitGroupBox");
    bitGroupBox->setLayout(bitHLayout);
    bitGroupBox->setTitle(tr("Bit Rate"));

    QHBoxLayout *funButtonHLayout=new QHBoxLayout;
    funButtonHLayout->addStretch(1);
    funButtonHLayout->addWidget(m_pRebootButton);
    funButtonHLayout->addWidget(m_pFunSaveAndRebootButton);

    QVBoxLayout *funVLayout=new QVBoxLayout;
    funVLayout->addLayout(hostHLayout);
    funVLayout->addWidget(bitGroupBox);
    funVLayout->addLayout(funButtonHLayout);

    QGroupBox *funGroupBox=new QGroupBox;
    funGroupBox->setObjectName("funGroupBox");
    funGroupBox->setTitle(tr("Function"));
    funGroupBox->setLayout(funVLayout);

    //EDID
    QHBoxLayout *topHLayout=new QHBoxLayout;
    topHLayout->addWidget(m_pEDIDComboBox);
    topHLayout->addWidget(m_pReadButton);
    topHLayout->addWidget(m_pEDIDComboBox2);
    topHLayout->addWidget(m_pReadButton2);

    QHBoxLayout *edidCheckHLayout=new QHBoxLayout;
    edidCheckHLayout->addWidget(m_pEditCheckBox);
    edidCheckHLayout->addWidget(m_pHDMICheckBox);
    edidCheckHLayout->addWidget(m_pDVICheckBox);
    edidCheckHLayout->addWidget(m_pEDIDHostComboBox);

    QHBoxLayout *edidHLayout=new QHBoxLayout;
    edidHLayout->addStretch(1);
    edidHLayout->addWidget(m_pWriteInButton);

    QVBoxLayout *edidVLayout=new QVBoxLayout;
    edidVLayout->addLayout(topHLayout);
    edidVLayout->addWidget(m_pTextEdit);
    edidVLayout->addLayout(edidCheckHLayout);
    edidVLayout->addLayout(edidHLayout);

    QGroupBox *edidGroupBox=new QGroupBox;
    edidGroupBox->setObjectName("edidGroupBox");
    edidGroupBox->setTitle(tr("EDID"));
    edidGroupBox->setLayout(edidVLayout);
    //layout
    QVBoxLayout *leftVLayout=new QVBoxLayout;
    leftVLayout->addWidget(netGroupBox);
    leftVLayout->addWidget(funGroupBox);

    QHBoxLayout *hLayout=new QHBoxLayout;
    hLayout->addLayout(leftVLayout);
    hLayout->addWidget(edidGroupBox);

    setLayout(hLayout);
}

AdvancedConigDialog::~AdvancedConigDialog()
{

}
